package com.gp.node.operator;

import com.gp.node.INode;
import com.stock.StockData;

//this class implement '-' operator
//functions description can be found at the interface IOperatorBinary
public class Sub extends IOperatorBinary {

	private static final long serialVersionUID = 5671325322446626111L;

	@Override
	public double getValue(StockData stock) {
		return right.getValue(stock) - left.getValue(stock); 
	}

	@Override
	public INode createNew()  {
		return new Sub();
	}
	
	@Override
	public INode copy() {
		Sub node = new Sub();
		node.setByCopy(this);
		return node;
	}
	
	@Override
	public String print(StockData stock) {
		return "(" + right.print(stock) + ") - (" + left.print(stock) + ")";
	}
	
	@Override
	public String print() {
		return "(" + right.print() + ") - (" + left.print() + ")";
	}

}
